package cn.cnsuh.controller.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet("/calServlet")
public class CalServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String numa = request.getParameter("numa");
		String numb = request.getParameter("numb");

		double a = Double.parseDouble(numa);
		double b = Double.parseDouble(numb);

		String msg = ""+(a + b) + " " + (a - b) + " " + (a * b) + " " + (a / b);
		
		System.out.println(msg);
//		System.out.println(res);
		response.setContentType("text/html;charset=utf-8");
		PrintWriter pw  = response.getWriter();
		pw.println(msg);
		pw.flush();
		pw.close();

	}

}
